Defines a string as a constant.
文字列を定数として定義します。
Const Text = Expression
Const Text = Expression
Text: Any constant name that follows the standard variable naming conventions.
Text: 定数名。命名規則は変数名のものと同じ。
A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified. Use the following statement to define a constant:
定数は変数の一種であり、プログラムの可読性を向上させるために使用します。定数は、特定の型の変数として定義されるわけではなく、コード中に存在する一種のプレースホルダとして使用されます。各定数の定義は 1 度だけが可能で、定義後に変更することはできません。定数の定義は、下記のステートメントで行います。
CONST ConstName=Expression
CONST ConstName=Expression
The type of expression is irrelevant. If a program is started, Office Basic converts the program code internally so that each time a constant is used, the defined expression replaces it.
型宣言は不要です。 型宣言は不要です。プログラムを実行すると、定数が使われているコード行を読み込むごとに、Office Basic が内部的な変換処理を行い、定義部で指定した表式に個々の定数を置き換えます。
Sub ExampleConst
Sub ExampleConst
Const iVar = 1964
Const iVar = 1964
Msgbox iVar
Msgbox iVar
Const sVar = "Program", dVar As Double = 1.00
Const sVar = "Program", dVar As Double = 1.00
Msgbox sVar & " " & dVar
Msgbox sVar & " " & dVar
end sub
end sub